package cn.pcManage.goodsManage.controller;

import cn.common.common.model.ServerResponse;
import cn.common.goods.model.BaseGoods;
import cn.pcManage.goodsManage.model.Goods;
import cn.pcManage.goodsManage.service.IGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by Zhang on 2019/1/12.
 */
@RestController
@RequestMapping("/goods")
public class GoodsController {
    @Autowired
    IGoodsService iGoodsService;

    @PostMapping(value = "/addGoods")
    public ServerResponse<?> addGoods(@RequestBody Goods goods){
        return iGoodsService.addGoods(goods);
    }

    @PostMapping(value = "/updateGoods")
    public ServerResponse<?> updateGoods(@RequestBody BaseGoods goods){
        return iGoodsService.updateGoods(goods);
    }

    @PostMapping(value = "/updateGoodsStatus")
    public ServerResponse<?> updateGoodsStatus(@RequestBody BaseGoods goods){
        return iGoodsService.updateGoodsStatus(goods);
    }

    @DeleteMapping(value = "/deleteGoods")
    public ServerResponse<?> deleteGoods(@RequestParam("id") Integer id){
        return iGoodsService.deleteGoods(id);
    }

    @PostMapping(value = "/getGoodsList")
    public ServerResponse<?> getGoodsList(@RequestBody BaseGoods goods){
        return iGoodsService.getGoodsList(goods);
    }

    @GetMapping(value = "/getGoodsInfo")
    public ServerResponse<?> getGoodsInfo(@RequestParam("id") Integer id){
        return iGoodsService.getGoodsInfo(id);
    }
}
